<extend name="Base/common"/>
<block name="style">
    <style type="text/css">
        .weui-cell_access .weui-cell__ftnone:after{border-style:none;}
        .pic_up{lwine-height: 150px;height:150px;text-align: center}
        .weui-gallery{background:rgba(0, 0, 0, 0.6);}
        .pic_up img{height: 150px;border: 1px dashed #ccc;border-radius:10px;}
    </style>
</block>
<block name="body">

    <empty name="info">
    <form class="formtijiao" action="" method="post">

        <div class="content">
            <div class="login-register clearfix">
                
                <div class="clearfix">


                    

                    <dl class="item-shfz">
                        <dt>
                            上传正面身份证 
                            
                        </dt>
                        <!-- <dd><img src="__IMG__/poto.jpg"/></dd> -->
                        <dd class="pic_up" f="1">
                            <img class="previewi " src="__IMG__/poto.jpg">
                            <input type="hidden" name="front_pic">
                        </dd>

                    </dl>
                    <dl class="item-shfz">
                        <dt>上传反面身份证 </dt>
                        <!-- <dd><img src="__IMG__/poto.jpg"/></dd> -->
                        <dd class="pic_up" f="2">
                            <img class="previewi " src="__IMG__/poto.jpg">
                            <input type="hidden" name="opposite_pic">
                        </dd>
                    </dl>
                   
                </div>
                
            </div>
            <input type="button"  value="确认提交" class="login-btn" />
            
        </div>
    </form>
     <div class="weui-cells__tips">
        <p class="login-tips"><em>温馨提示</em>：<br>1、请上传清晰的对应证件照片，必须清晰可见证件内容。<br>
    </div>
    <else />
        <div class="weui-cells">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <p>真实姓名</p>
                </div>
                <div class="weui-cell__ft">{$info.realname}</div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <p>身份证号</p>
                </div>
                <div class="weui-cell__ft">{$info.identityNo|substr=0,2}****{$info.identityNo|substr=-2}</div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <p>民族</p>
                </div>
                <div class="weui-cell__ft">{$info.nation}</div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <p>性别</p>
                </div>
                <div class="weui-cell__ft">{$info.gender}</div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <p>地址</p>
                </div>
                <div class="weui-cell__ft">{$info.address}</div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <p>签发机关</p>
                </div>
                <div class="weui-cell__ft">{$info.issuing_authority}</div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <p>有效期限</p>
                </div>
                <div class="weui-cell__ft">{$info.validity_period}</div>
            </div>
        </div>
        <div class="weui-cells__tips">
        <p class="login-tips"><em>温馨提示</em>：<br>1、如信息有误，请联系客服人员修改。<br>
    </div>
    </empty>
   


</block>
<block name="script">
     <script >



        Zepto(function($){

            $('.login-btn').click(function(){

                
                var data =  $('form').serialize();
                var Url  = $('form').attr('action');
                
                $.ajax({
                    type:'post',
                    url:Url,
                    data:data,
                    // dataType:'json',
                    beforeSend:function(XMLHttpRequest){
                        popup.loading('正在提交中');
                        //ShowLoading();正在提交中
                    },
                    success:function(m){
                        confirm(m);
                        location.href="{:U('realname')}";
                    },
                    complete:function(XMLHttpRequest,textStatus){
                       popup.noloading();
                    },
                    error:function(m){
                        //请求出错处理
                        popup.alert(m.XMLHttpRequest+'////')
                        popup.alert('请求出错处理');
                        return false;
                    }
                });

            }) ;

            $(".demo_pic").on("click", function(){
                $('#galleryImg').attr("style", "background-image:url('"+this.getAttribute("data-src")+"'");
                $('#gallery').fadeIn(100);
            });
            $('#gallery').on("click", function(){
                $(this).fadeOut(100);
            });

        });

    </script>

    <script>
        wx.config({
            debug: false,
            appId: '{$weixinconfig.appId}',
            timestamp: '{$weixinconfig.timestamp}',
            nonceStr: '{$weixinconfig.nonceStr}',
            signature: '{$weixinconfig.signature}', 
            jsApiList: [
                'chooseImage',
                'previewImage',
                'uploadImage',
                'downloadImage',
                'getLocalImgData'
            ]
        });
        wx.ready(function () {
// 5.1 拍照、本地选图
            var images = {
                localId: [],
                serverId: []
            };

 // 上传图片
            $(".pic_up").click(function(){ 
                var path='';
                var that =$(this);
                images.localId = [];
                wx.chooseImage({
                    count: 1, // 默认9
                    sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
                    sourceType: [ 'camera','album'], // 可以指定来源是相册还是相机，默认二者都有 'album',
                    success: function (res) {  
                        images.localId = res.localIds;
                        if (images.localId.length == 0) {
                            alert('请先使用 chooseImage 接口选择图片');
                            return;
                        }
                        if(images.localId.length > 1) {
                            alert('目前仅支持单张图片上传,请重新上传');
                            images.localId = [];
                            return;
                        }
                        var i = 0, length = images.localId.length;
                        images.serverId = [];
                        function upload() {
                            wx.uploadImage({
                                localId: images.localId[i],
                                success: function (res) {
                                    i++;
                                    that.find('img.previewi').attr('src',images.localId[0]);
                                    images.serverId.push(res.serverId);
                                    that.find('input[type=hidden]').val(images.serverId[0]);
                                    if (i < length) {
                                        upload();
                                    }
                                },
                                fail: function (res) {
                                    alert(JSON.stringify(res));
                                }
                            });
                        }
                        upload();
                    }
                });


                



            });
        });


    </script>
</block>